<@override name="content">
<div class="row">
  <div class="span4 offset3">
    <form class="form-horizontal" id="editUserForm" action="user/update" method="post">
      <fieldset>
        <legend>Basic Information</legend>
        <div class="control-group <#if emailMsg??>error</#if>">
          <label class="control-label" for="inputEmail">Email</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="icon-envelope"></i></span>
              <input type="email" id="inputEmail" name="user.email" value="${user.email!}" required>
            </div>
            <p class="text-error">${emailMsg!}</p>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputNick">Nick</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-user-plus" aria-hidden="true"></i></span>
              <input type="text" id="inputNick" name="user.nick" value="${user.nick!}" required>
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputSchool">School</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-university" aria-hidden="true"></i></span>
              <input type="text" minlength="3" id="inputSchool" name="user.school" value="${user.school!}">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputLanguage">Favorite Language</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-language" aria-hidden="true"></i></span>
              <select id="inputLanguage" name="user.language">
                <#if program_languages??>
                  <#list program_languages.keySet() as key>
                    <option value="${key!}"
                            <#if user.language==key>selected</#if>>${program_languages.get(key)!}</option>
                  </#list>
                </#if>
              </select>
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Share Code?</label>
          <div class="controls">
            <label class="radio inline">
              <input type="radio" name="user.shareCode" class="shareCode" id="shareCode1" value="true"<#if user.shareCode==true>
                     checked</#if>>
              True
            </label>
            <label class="radio inline">
              <input type="radio" name="user.shareCode" class="shareCode" id="shareCode2" value="false"<#if user.shareCode==false>
                     checked</#if>>
              False
            </label>
          </div>
        </div>
      </fieldset>
      <fieldset>
        <legend>Person Information</legend>
        <div class="control-group">
          <label class="control-label" for="inputRealName">Real Name</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-user-secret" aria-hidden="true"></i></span>
              <input type="text" minlength="2" maxlength="20" id="inputRealName" name="user.realName"
                     value="${user.realName!}">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputPhone">Phone</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-mobile" aria-hidden="true"></i></span>
              <input type="tel" minlength="7" maxlength="15" id="inputPhone" name="user.phone" value="${user.phone!}">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputQQ">QQ</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-qq" aria-hidden="true"></i></span>
              <input type="number" minlength="5" maxlength="12" id="inputQQ" name="user.qq" value="${user.qq!}">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputBlog">Blog</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-link" aria-hidden="true"></i></span>
              <input type="url" id="inputBlog" name="user.blog" value="${user.blog!}">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputGender">Gender</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-genderless" aria-hidden="true"></i></span>
              <select id="inputGender" name="user.gender">
                <option value="secret"<#if user.gender=="secret">selected</#if>>Secret</option>
                <option value="male"<#if user.gender=="male">selected</#if>>Male</option>
                <option value="female"<#if user.gender=="female">selected</#if>>Female</option>
              </select>
            </div>
          </div>
        </div>
      </fieldset>
      <fieldset>
        <legend>Security</legend>
        <div class="control-group <#if passwordMsg??>error</#if>">
          <label class="control-label" for="inputOldPass">Old Password</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-unlock-alt" aria-hidden="true"></i></span>
              <input type="password" minlength="6" maxlength="20" id="inputOldPass" name="oldpass"
                     placeholder="your current password" required>
            </div>
            <p class="text-error">${passwordMsg!}</p>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputNewPass">New Password</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-lock" aria-hidden="true"></i></span>
              <input type="password" minlength="6" maxlength="20" id="inputNewPass" name="user.password">
            </div>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="inputConfirmPass">Confirm Password</label>
          <div class="controls">
            <div class="input-prepend">
              <span class="add-on"><i class="fa fa-lock" aria-hidden="true"></i></span>
              <input type="password" minlength="6" maxlength="20" id="inputConfirmPass" name="repass">
            </div>
            <p class="text-error">${confirmMsg!}</p>
          </div>
        </div>
        <fieldset>
          <div class="control-group">
            <div class="controls">
              <input type="hidden" name="user.name" value="${user.name!}">
              <button type="submit" class="btn btn-primary"><i class="fa fa-save" aria-hidden="true"></i> Save</button>
              <a class="btn btn-warning" href="user/profile/${user.name!}"><i class="fa fa-undo" aria-hidden="true"></i> Cancel</a>
            </div>
          </div>
    </form>
  </div>
</div>
</@override>

<@override name="scripts">
<script src='assets/jquery-validation/dist/jquery.validate.min.js' type='text/javascript'></script>
<script type="text/javascript">
  $().ready(function () {
    $("#editUserForm").validate();
    $('#inputEmail').tooltip({
      'trigger': 'focus',
      'title': 'Your email is required for recovering password.',
      'placement': 'right'
    });
    $('#inputNick').tooltip({'trigger': 'focus', 'title': 'Normal user cannot use html markup.', 'placement': 'right'});
    $('#inputLanguage').tooltip({
      'trigger': 'focus',
      'title': 'Your favorite programming language.',
      'placement': 'right'
    });
    $('#shareCode1').tooltip({
      'title': 'You can access others\' AC code if you solved the same problem.',
      'placement': 'right'
    });
    $('#inputQQ').tooltip({'trigger': 'focus', 'title': 'You can leave it empty.', 'placement': 'right'});
    $('#inputPhone').tooltip({'trigger': 'focus', 'title': 'You can leave it empty.', 'placement': 'right'});
    $('#inputBlog').tooltip({'trigger': 'focus', 'title': 'e.g.: http://www.blog.com.', 'placement': 'right'});
    $('#inputOldPass').tooltip({
      'trigger': 'focus',
      'title': 'This is required to update your profile.',
      'placement': 'right'
    });
    $('#inputRealName').tooltip({
      'trigger': 'focus',
      'title': 'Only yourself and admin can access this.',
      'placement': 'right'
    });
    $('#inputNewPass').tooltip({
      'trigger': 'focus',
      'title': 'Input your new password only if you want to change.',
      'placement': 'right'
    });
    $('#inputConfirmPass').tooltip({'trigger': 'focus', 'title': 'Repeat your new password.', 'placement': 'right'});
  });
</script>
</@override>
<@extends name="../common/_layout.html" />
